package com.itheima.d8_interface2.Demo;

public class ClassDateInterImpl1 implements ClassDateInter{
    // 实现类，实现接口中的打印学生信息 需要传过来参数
    private Student[] students;

    public ClassDateInterImpl1(Student[] students) {
        this.students = students;
    }

    @Override
    public void printStudentInfo() {
    //打印班级全部学生的信息
        for (int i = 0; i < students.length;i++) {
            //获取每个学生的数据
            Student s = students[i];
            System.out.println("姓名：" + s.getName() + " 性别：" + s.getSex() + " 成绩：" + s.getScore());

        }
    }

    @Override
    public void printStudentAvgScore() {
        double sum = 0;
        for (int i = 0; i < students.length; i++) {
            Student s = students[i];
            sum += s.getScore();
        }
        System.out.println("平均分：" + sum / students.length);

    }
}
